import { PureComponent } from 'react';
import moment from 'moment';
import {
    Row,
    Col,
    Form,
    Input,
    Select,
    Modal,
    Cascader,
    DatePicker
} from 'antd';
const FormItem = Form.Item;
const { Option } = Select;
import { dicTextByCodePcode,dicListByPcode } from '@/utils/dictionary'


@Form.create()
class CreateForm extends PureComponent {

	constructor(props) {
	    super(props);
	    this.state = {

	    }
	}


	okHandle = () => {
		const { form,handleAdd } = this.props;

	    form.validateFields((err, fieldsValue) => {
		        if (err) return;
		        form.resetFields();
			   	if(fieldsValue.a1507) {
			   				fieldsValue.a1507 = moment(fieldsValue.a1507._d).format("YYYY-MM-DD");
			   			}
			   	if(fieldsValue.a1511) {
			   				fieldsValue.a1511 = moment(fieldsValue.a1511._d).format("YYYY-MM-DD");
			   			}
			    handleAdd(fieldsValue,'TrainInfo');
		});
	};


	resetButton = () => {

	};

  render() {
    const {form: {getFieldDecorator}, modalVisibleByTrainInfo,handleModalVisible} = this.props;

return (
    <Modal
width={800}
destroyOnClose
title="添加培训信息"
visible={modalVisibleByTrainInfo}
onOk={this.okHandle}
onCancel={() => handleModalVisible(false,"TrainInfo")}
afterClose={() => this.resetButton()}
>
<Form  layout="vertical">
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
		    <Col md={12} sm={24}>
		      <FormItem  label="培训班名称">
		          {getFieldDecorator('a1531', {
		          rules: [{ required: false, message: '请输入1-10个字符',max: 10}],
		          })(<Input placeholder="1-10个字符"/>)}
		      </FormItem>
		    </Col>
		
		    <Col md={12} sm={24}>
		      <FormItem  label="培训班类别">
		          {getFieldDecorator('a1534', {
		            rules: [{ required: false, message: '请选择'}],
		          })(
		            <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		            	{dicListByPcode('AE') != undefined?dicListByPcode('AE').map((item,index) => {
		            		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		            	}):null}
		            </Select>
		          )}
		      </FormItem>
		    </Col>
		
		</Row>
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
		    <Col md={12} sm={24}>
		      <FormItem  label="培训完成情况">
		          {getFieldDecorator('a1544',{
		          })(
		          	<Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		          		{dicListByPcode('AE') != undefined?dicListByPcode('AE').map((item,index) => {
		          			return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		          		}):null}
		          	</Select>
		          )}
		      </FormItem>
		    </Col>
		    <Col md={12} sm={24}>
		      <FormItem  label="培训时所在单位及职务">
		          {getFieldDecorator('a1546', {
		          rules: [{ required: false, message: '1-40个字符'}],
		          })(<Input placeholder="1-40个字符" />)}
		      </FormItem>
		    </Col>
		
		</Row>
		
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
		<Col md={12} sm={24}>
		      <FormItem  label="承训机构名称">
		          {getFieldDecorator('a1519', {
		          rules: [{ required: false, message: '请选择'}],
		          })(
		          	<Input placeholder="1-40个字符" />
		          )}
		      </FormItem>
		    </Col>
		
		    <Col md={12} sm={24}>
		      <FormItem  label="培训地点">
		          {getFieldDecorator('a1521',{
		            rules: [{ required: false, message: '请选择！'}],
		          })(
		          	<Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		              {dicListByPcode('R1') != undefined?dicListByPcode('R1').map((item,index) => {
		                return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		              }):null}
		            </Select>
		          )}
		      </FormItem>
		    </Col>
		
		</Row>
		
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
		
		    <Col md={12} sm={24}>
		      <FormItem  label="培训主办单位名称">
		          {getFieldDecorator('a1514_1', {
		          rules: [{ required: false, message: '1-40个字符'}],
		          })(
		            <Input placeholder="1-40个字符" />
		          )}
		      </FormItem>
		    </Col>
		    <Col md={12} sm={24}>
		      <FormItem  label="主办单位机构代码">
		          {getFieldDecorator('a1514_2', {
		          rules: [{ required: false, message: '1-40个字符'}],
		          })(<Input placeholder="1-40个字符" />)}
		      </FormItem>
		    </Col>
		
		</Row>
		
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
		
		    <Col md={12} sm={24}>
		      <FormItem  label="主办单位级别">
		          {getFieldDecorator('a1517',{
		                rules: [{ required: false, message: '请选择！'}],
		              })(
		              	<Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		                  {dicListByPcode('R1') != undefined?dicListByPcode('R1').map((item,index) => {
		                    return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		                  }):null}
		                </Select>
		              )}
		          </FormItem>
		    </Col>
		
		   	<Col  md={12} sm={24}>
		   	  <FormItem  label="开始日期">
		   	      {getFieldDecorator('a1507', {
		   	        rules: [{ required: false, message: '请选择'}],
		            })(
		            <DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>
		            )}
		          </FormItem>
		   	</Col>
		
		</Row>
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
			<Col md={12} sm={24}>
			  <FormItem  label="结束日期">
			      {getFieldDecorator('a1511', {
			        rules: [{ required: false, message: '请选择'}],
			        })(
			        <DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>
			        )}
			  </FormItem>
			</Col>
		
		  <Col md={12} sm={24}>
		    <FormItem  label="培训离岗状态">
		        {getFieldDecorator('a1504', {
		          rules: [{ required: false, message: '请选择'}],
		          })(
		          <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		          	{dicListByPcode('JK') != undefined?dicListByPcode('JK').map((item,index) => {
		          		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		          	}):null}
		          </Select>
		        )}
		    </FormItem>
		  </Col>
		</Row>
		
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
		
		    <Col md={12} sm={24}>
		      <FormItem  label="培训证书编号">
		          {getFieldDecorator('a1529', {
		          rules: [{ required: false, message: '1-40个字符'}],
		          })(
		            <Input placeholder="1-40个字符" />
		          )}
		      </FormItem>
		    </Col>
		    <Col md={12} sm={24}>
		      <FormItem  label="免训原因">
		          {getFieldDecorator('a1548', {
		          rules: [{ required: false, message: '1-40个字符'}],
		          })(<Input placeholder="1-40个字符" />)}
		      </FormItem>
		    </Col>
		
		</Row>
		
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
		
		    <Col md={12} sm={24}>
		      <FormItem  label="免训标识">
		          {getFieldDecorator('a1547', {
		          rules: [{ required: false, message: '1-40个字符'}],
		          })(
		            <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		            	{dicListByPcode('JK') != undefined?dicListByPcode('JK').map((item,index) => {
		            		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		            	}):null}
		            </Select>
		          )}
		      </FormItem>
		    </Col>
		
		
		</Row>

</Form>
</Modal>
);
  }

}

export default CreateForm;
